#include <stdlib.h>
#include <string>
#include <iostream>
// #include <tchar.h>
#include "Cv310Text.h"
#include <opencv2/opencv.hpp>

using namespace std;


std::wstring ANSIToUnicode(const std::string & str)
{
    std::wstring ret;
    std::mbstate_t state = {};
    const char *src = str.data();
    size_t len = std::mbsrtowcs(nullptr, &src, 0, &state);
    if (static_cast<size_t>(-1) != len) {
        std::unique_ptr< wchar_t [] > buff(new wchar_t[len + 1]);
        len = std::mbsrtowcs(buff.get(), &src, len, &state);
        if (static_cast<size_t>(-1) != len) {
            ret.assign(buff.get(), len);
        }
    }
    return ret;
}


int main(int argc, char *argv[])
{
    std::string font_file = "./simfang.ttf";
    Cv310Text text(font_file.c_str());
    cv::Mat img = cv::imread("./1.jpg");
    if(img.empty())
    {
      return 0;
    }

    std::string str = "世界和平";
    text.putText(img, L"OPENCV 显示中文", cvPoint(30, 85), CV_RGB(255, 0, 0));
    text.putText(img, L"OPENCV 显示中文", cvPoint(30, 135), CV_RGB(255, 100, 200));
    cv::imshow("img", img);
    cv::waitKey(0);
    return 0;
}
